Socket
Socket
Sign inDemoInstall

@turf/truncate

Package Overview
Dependencies
Maintainers
4
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/truncate

turf truncate module


Version published
Weekly downloads
478K
decreased by-8.98%
Maintainers
4
Weekly downloads
 
Created

What is @turf/truncate?

@turf/truncate is a module in the Turf.js library that is used to truncate the precision of coordinates in GeoJSON data. This can be useful for reducing the size of GeoJSON files or for ensuring consistent precision across datasets.

What are @turf/truncate's main functionalities?

Truncate Coordinates

This feature allows you to truncate the coordinates of a GeoJSON object to a specified precision. In this example, the coordinates of a point are truncated to 3 decimal places.

const truncate = require('@turf/truncate');
const point = { "type": "Feature", "geometry": { "type": "Point", "coordinates": [70.123456789, 40.987654321] } };
const truncated = truncate(point, { precision: 3 });
console.log(truncated);

Truncate with Custom Options

This feature allows you to truncate the coordinates of a GeoJSON object with custom options. In this example, the coordinates of a LineString are truncated to 2 decimal places, and the number of coordinates is also limited to 2.

const truncate = require('@turf/truncate');
const lineString = { "type": "Feature", "geometry": { "type": "LineString", "coordinates": [[70.123456789, 40.987654321], [71.123456789, 41.987654321]] } };
const truncated = truncate(lineString, { precision: 2, coordinates: 2 });
console.log(truncated);

Other packages similar to @turf/truncate

Keywords

FAQs

Package last updated on 10 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc